/// @tags: KDTree
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using std::cin, std::cout;
using std::max, std::min;

namespace BlueQuantum {

typedef std::vector<int> Vector;
typedef long long ll;

constexpr int N = 1e5 + 3, k(2), inf(1e9 + 5);

int n, m, f;

struct point {
  int d[2], id;

  inline point() { d[0] = d[1] = id = 0; }

  inline point(const int &x, const int &y) {
    d[0] = x;
    d[1] = y;
  }

  inline bool operator<(const point &p) const {
    if (d[f] != p.d[f]) return d[f] < p.d[f];
    for (int i(0); i < k; i++)
      if (d[i] != p.d[i]) return d[i] < p.d[i];
    return 0;
  }
} a[N];

struct tree {
  Vector down, self;
  point range, mn, mx;
  tree *son[2];
  static tree *null;
  void *operator new(size_t size);
  inline tree() { son[0] = son[1] = null; }
  inline tree(const point &x) : range(x), mn(x), mx(x) {
    static bool init(0);
    if (!init) {
      init = 1;
      null = new tree;
      null->son[0] = null->son[1] = null;
      for (int i(0); i < k; i++) null->mn.d[i] = inf, null->mx.d[i] = -inf;
    }
    son[0] = son[1] = null;
  }
  inline const void pushup() {
    for (int i(0); i < k; i++)
      mx.d[i] = max(range.d[i], max(son[0]->mx.d[i], son[1]->mx.d[i])),
      mn.d[i] = min(range.d[i], min(son[0]->mn.d[i], son[1]->mn.d[i]));
  }
  inline const bool at(const point &a, const point &b) {
    for (int i(0); i < k; i++)
      if (range.d[i] > b.d[i] || range.d[i] < a.d[i]) return 0;
    return 1;
  }
  inline const bool in(const point &a, const point &b) {
    for (int i(0); i < k; i++)
      if (mn.d[i] < a.d[i] || mx.d[i] > b.d[i]) return 0;
    return 1;
  }
  inline const bool out(const point &a, const point &b) {
    for (int i(0); i < k; i++)
      if (mn.d[i] > b.d[i] || mx.d[i] < a.d[i]) return 1;
    return 0;
  }
} * root, *tree::null;

#define null tree::null

char memory_pool[N * sizeof(tree)], *tail(memory_pool + sizeof(memory_pool));

inline void *tree::operator new(size_t size) { return tail -= size; }

inline tree *build(const int &l, const int &r, const int &d) {
  if (l > r) return null;
  const int mid(l + r >> 1);
  f = d;
  std::nth_element(a + l, a + mid, a + r + 1);
  tree *p(new tree(a[mid]));
  if (l == r) return p;
  p->son[0] = build(l, mid - 1, (d + 1) % k);
  p->son[1] = build(mid + 1, r, (d + 1) % k);
  p->pushup();
  return p;
}

inline const void insert(tree *p, const point &a, const point &b, const int &c) {
  if (p == null) return;
  if (p->out(a, b)) return;
  if (p->in(a, b)) return p->down.push_back(c);
  if (p->at(a, b)) p->self.push_back(c);
  insert(p->son[0], a, b, c);
  insert(p->son[1], a, b, c);
}

int cnt[N];
ll sum, ans[N];
inline const void add(const int &c) { sum += cnt[c]++; }
inline const void del(const int &c) { sum -= --cnt[c]; }

inline void query(tree *p) {
  if (p == null) return;
  for (Vector::iterator i(p->down.begin()); i != p->down.end(); i++) add(*i);
  for (Vector::iterator i(p->self.begin()); i != p->self.end(); i++) add(*i);
  ans[p->range.id] = sum;
  for (Vector::iterator i(p->self.begin()); i != p->self.end(); i++) del(*i);
  query(p->son[0]);
  query(p->son[1]);
  for (Vector::iterator i(p->down.begin()); i != p->down.end(); i++) del(*i);
}

inline int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; a[i].id = i, ++i)
    for (int j = 0; j < k; ++j) cin >> a[i].d[j];
  root = build(1, n, 0);
  for (int x1, y1, x2, y2, c; m--;)
    cin >> x1 >> y1 >> x2 >> y2 >> c, insert(root, point(x1, y1), point(x2, y2), c);
  query(root);
  for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("square.in", "r", stdin);
  freopen("square.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
